package TessTest;

/**
 * Created by wrh on 17-9-30.
 */

import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.TesseractException;
import org.slf4j.LoggerFactory;

import java.io.File;

public class OCR extends Thread{
    static final org.slf4j.Logger logger = LoggerFactory.getLogger(OCR.class);
    ITesseract instance;
    File img;
    public OCR(ITesseract instance,String img){
        this.instance=instance;
        this.img = new File(img);

    }
    @Override
    public void run() {
        logger.info(img.getName()+"图像识别开始");

        // ITesseract instance = new Tesseract1(); // JNA Direct Mapping

        try {
            String result = instance.doOCR(img);
            System.out.println(result);
        } catch (TesseractException e) {
            System.err.println(e.getMessage());
        }

        logger.info(img.getName()+"图像识别结束");
        super.run();
    }
}